/*
 * Copyright (c) 2025, 廖树财, <study_2030@163.com>
 *
 * PEE2.0-YCYW-HY is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2     
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
#pragma once
#include "define.h"
#include "cjson/cJSON.h"
#include "common.h"
#include <stdlib.h>

void IOTA_getLocalTime(char *pcLocalTime);

char *IOTA_getLocalTimeString();

bool StructToJson_DeviceAdd(unsigned int uiMid, ST_IOTA_DEVICE_INFO *stDevices, char **pcJson);

bool StructToJson_DeviceStatusUpdate(unsigned int uiMid, ST_IOTA_DEVICE_STATUS *stStatuss, char **pcJson);

bool StructToJson_DeviceQuery(unsigned int uiMid, char *pcNodeId, char **pcJson);

bool StructToJson_ServiceDataReport(char *pcDeviceId, char *pcServiceId, char *pcServiceProperties, char **pcJson);

bool StructToJson_ServiceCommandResponse(unsigned int uiMid, unsigned int uiResultCode, char *pcCommandResponse, char **pcJson);

bool StructToJson_ServiceCustomTopicReport(ST_IOTA_BatchReportProperties *pstDevInfo, char **pcJson);

bool StructToJson_LogUploadRes(char **pcJson, ST_IOTA_LOG_RES *pcStatusDecs, bool isstring);

bool StructToJson_LogRuleRes(char *pcJson, ST_IOTA_LOG_RES *pcStatusDecs);

bool JsonToStruct_Login(char *pcJson, ST_IOTA_LOGIN_RES_V1 *pcStatusDecs);

bool JsonToStruct_Login_v1(char *pcJson, ST_IOTA_LOGIN_RES *pcStatusDecs);

bool JsonToStruct_LoginAuth(char *pcJson, ST_IOTA_AUTH_RES *pcStatusDecs);

bool JsonToStruct_FileRes(char *pcJson, ST_IOTA_FILE_RES *pcStatusDecs);

bool JsonToStruct_LogFileData(char *pcJson, ST_IOTA_FILE_DATA *pcStatusDecs);

bool JsonToStruct_LogRule(char *pcJson, ST_IOTA_LOG *pcStatusDecs);

bool JsonToStruct_DeviceAddRsp(char *pcJson, unsigned int *uiMid, int *iStatusCode, char *pcStatusDecs, ST_IOTA_ADD_DEVICE_RSP *stRsp);

bool JsonToStruct_DeviceStatusUpdateRsp(char *pcJson, unsigned int *uiMid, int *iStatusCode, char *pcStatusDecs, ST_IOTA_UPDATE_STATUS_RSP *stRsp);

bool JsonToStruct_DeviceQueryRsp(char *pcJson, unsigned int *uiMid, int *iStatusCode, char *pcStatusDecs, ST_IOTA_DEVICE_INFO *stRsp, char *pcCount, char *pcMarker);

bool JsonToStruct_Command(char *pcJson, ST_IOTA_COMMAND *stCommand);

bool JsonToStruct_Response(char *pcJson, unsigned int *uiMid, int *iStatusCode, char *pcStatusDecs);

bool JsonToStruct_LogUpload(char *pcJson, ST_IOTA_LOG *pcStatusDecs);

int JsonToStruct_ROMACONF(char *pcJson, IOTA_ROMA_CONF_V1 *pcStatusDecs);

bool StructToJson_WeakPasswdRes(char **pcJson, ST_IOTA_WEAKPASSWD *pcStatusDecs);

int JsonToStruct_FILECONF(char *pcJson, IOTA_FILE_CONF_V1 *pcStatusDecs);

bool StructToJson_NETWORKLIST(char **pcJson, ST_IOTA_LOG_RES *pcStatusDecs, int num, PIOTA_NETWORKLIST_PARAM_V1 inputpar);

bool StructToJson_DictionaryDetele(char **pcJson, ST_IOTA_LOG_RES *pcStatusDecs);

bool StructToJson_PolicySecurity_Info(char **pcJson, ST_IOTA_LOG_RES *pcStatusDecs,cJSON* info_json);

bool StructToJson_policy_video_info(char **pcJson, ST_IOTA_LOG_RES *pcStatusDecs,cJSON* video_json);

bool StructToJson_firewall(char** pcJson, ST_IOTA_LOG_RES* pcStatusDecs, RuleCollection* db_ipt_entries,char* des);
